<!--
 * @Author: your name
 * @Date: 2022-03-29 15:32:42
 * @LastEditTime: 2022-03-29 15:40:43
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\Object.create220329.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Object.create</title>
</head>
<body>
  <script>
    //利用object.create实现继承
    function father(name){
      var name="geyao"
      this.name = name;
     
    }
    function children(){
        father.call(this)
    }

    children.prototype=Object.create(father.prototype);
    children.prototype.constructor=children

    var geyao=new children()
    console.log(geyao.name,"geyao") //geyao
  </script>
</body>
</html>